<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>


<script>
    /* -----------------------------------------------------------*/
/*    function Cat(name,color){
        this.name = name;
        this.color = color;
        this.eat = function () {
            alert('吃老鼠')
        }
    }
    var cat1 = new Cat('tom','red')
    cat1.eat();*/


    /* -----------------------------------------------------------*/
    function Cat(name,color){
        this.name = name;
        this.color = color;
    }
    Cat.prototype.type = "猫科动物";
    Cat.prototype.eat = function(){
        alert("吃老鼠")
    };

    var cat1 = new Cat("大毛","黄色");
    var cat2 = new Cat("二毛","黑色");
    alert(cat1.type); // 猫科动物
    cat1.eat(); // 吃老鼠
</script>
</html>